package com.tosmart.jorm.annotation;

import java.lang.annotation.*;

/**
 * In addition to supporting the value of the value
 * of the Entity and the associated database tables
 * outside, JORM framework also supports foreign keys
 * associated with mapping.
 * <p/>
 * With the @OrmRefer similar, We use A typical use case:
 * <p/>
 * A Log record, there is an associated user ID.
 * In User Entity class, JORM framework can be based
 * on the log.user_id (related to user.id, primary key)
 * to automatically associate a list Log objects.
 * <p/>
 * Worthy of note are:
 * JORM framework for automatically mapping is only
 * associated with the object, rather than automatically
 * modify and save the association.
 *
 * @author tosmart@gmail.com
 * @see JormRefer
 * @see JormMap
 */
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.FIELD)
public @interface JormReferList {
    /**
     * This tag indicates that the type mapping in
     * the list of Entity. It must be another Entity
     * class (the class is JormEntity comment tags).
     *
     * @return Entity type mapping in the list
     */
    Class entityClass();

    /**
     * List of foreign keys in another Entity class.
     * It is a list that map to the primary key list
     * of Current Entity class.
     * <p/>
     * The order of the list of foreign keys list should
     * be the same to primary key list of Current Entity class.
     *
     * @return the foreign key list of another Entity class
     */
    String[] foreignKeys() default {};
}
